import tongInput from "@/components/basicItem/input";
const formLists = [
  {
    type: "input",
    placeholder: "我是你爹",
    field: "input",
  },
  {
    type: "button",
    text: "我是一个按钮",
    disabled: true,
    field: "button",
  },
];
// const formData = {
//   input: "后端给我的一个input的value",
//   button: "后端给我的一个button的value",
// };
export default {
  data() {
    return {
      formData: {
        input: "后端给我的一个input的value",
        button: "后端给我的一个button的value",
      },
    };
  },
  render: function (createElement) {
    const itemElements = formLists.map((item, index) => {
      let component;
      switch (item.type) {
        case "input":
          component = createElement(tongInput, {
            on: {
              fuck: (value) => {
                this.formData[item.field] = value;
                console.log("formData", this.formData);
              },
            },
            props: {
              placeholder: item.placeholder,
              value: this.formData[item.field],
            },
          });
          break;
        case "button":
          component = createElement(
            "el-button",
            {
              on: {
                click: () => {},
              },
              props: {},
            },

            item.text
          );
          break;
        default:
          component = createElement("div", "Default Component");
          break;
      }
      return createElement("div", { key: index }, [component]);
    });
    return createElement("div", itemElements);
  },
};
